package pl.auction_search.views;

import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;

import pl.auction_search.model.ISearchResultModel.ISearchCategory;
import pl.auction_search.search.Result;

class ViewLabelProvider extends LabelProvider {
	protected static final String DEFAULT_IMAGE_KEY = ISharedImages.IMG_OBJ_ELEMENT;
	
	public String getText(Object obj) {
		return obj.toString();
	}

	public Image getImage(Object obj) {
		if (obj instanceof Result) {
			return getImage(ISharedImages.IMG_OBJ_FILE);
		}else if(obj instanceof ISearchCategory<?>){
			return getImage(ISharedImages.IMG_OBJ_FOLDER);
		}
		return getImage(DEFAULT_IMAGE_KEY);
	}

	private Image getImage(String imageKey) {
		return PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
	}
}